package com.tgy.crud.listener;

import com.tgy.crud.domain.User;
import com.tgy.crud.service.SendMessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import org.springframework.amqp.core.Message;

@Slf4j
@Component
public class RabbitMQListener {


    @Autowired
    private SendMessageService sendMessageService;

    @RabbitListener(queues = "news")
    public void handleMessage(User user){

        log.info("body {}", user.getClass());
    }


    @RabbitListener(queues = "login.email")
    public void handleSendEmailMessage(User user){

        sendMessageService.sendEmail(user);
    }

    @RabbitListener(queues = "login.message")
    public void handleSendMessage(User user){

        sendMessageService.sendMessage(user);
    }

}
